home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MoreFinderEvents.h
-
- Contains: Functions to help you build and sending Apple events to the Finder.
-
- Written by: Andy Bachorski
-
- Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/21/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- #if PRAGMA_ONCE
- #pragma once
- #endif
-
- #ifndef _MORE_FINDER_EVENTS_
- #define _MORE_FINDER_EVENTS_
-
-
- //******************************************************************************
- // A private conditionals file to setup the build environment for this project.
-
- #include "PrivateConditionals.h"
-
-
- //********** Universal Headers ****************************************
-
- #include <Aliases.h>
- #include <Folders.h>
- #include <Icons.h>
- #include <OSA.h>
- #include <Processes.h>
- #include <Types.h>
-
-
- //******************************************************************************
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT
- #pragma import on
- #endif
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
- #endif
-
- //******************************************************************************
-
-
- enum {
- kFinderFileType = 'FNDR',
- kFinderCreatorType = 'MACS',
- kFinderProcessType = 'FNDR',
- kFinderProcessSignature = 'MACS'
- };
-
-
- /*****************************************************************************
- IMPORTANT NOTE ABOUT IDLE FUNCTIONS
-
- Many of the functions in this library take an AEIdleUPP as a parameter.
- You can use this parameter to supply an idle function for use in the call
- to AESend.
-
- If the idleProcUPP parameter is set to nil, no idle function is used when
- AESend is called, and the send mode will be AENoReply.
-
- If an AEIdleUPP is supplied in the idleProcUPP parameter, it is used when
- AESend is called, and the send mode will be AEWaitReply.
-
- There is a simple idle function supplied with this library. It's VERY simple.
- It ignores any event it may receive, and returns a resonable sleep value
- and a nil mouse region. This is not enough for any but the most trivial
- of applications.
-
- If the application using these functions has windows, then the idle function
- will receive update, activate, osEvt, and null events. Because of this,
- you must supply a more complete and robust idle function than the defaule
- idle function included with this library.
-
- In most cases, the events received by the idle function can simply be
- sent to the application's do event routine. You will also want to supply
- appropriate values for the sleep and mouseRgn parameters.
-
- See Inside Macintosh: Interapplicatins Communications for more about
- idle functions.
-
- *****************************************************************************/
-
- pascal OSErr MFESetSelectionToNone( const AEIdleUPP idleProcUPP );
- /*
- Sets the Finder's selection to nothing by telling it to set it's
- selection to an empty list.
-
- See note about idle functions above.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEChangeFolderViewNewSuite( const FSSpecPtr fssPtr,
- const long viewStyle,
- const AEIdleUPP idleProcUPP );
- /*
- Send an Apple event to Finder 7.5 or later to set the view of the window
- for the folder pointed to by the FSSpec.
-
- fssPtr ==> FSSpec for the folder whose view is to be set
- viewStyle ==> A view constant, as defined in AERegistry.h
- idleProcUPP ==> nil for default, or UPP for the idle function to use
-
- Requires that the folder's window be open, otherwise an error is returned
- in the reply event.
-
- See note about idle functions above.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEChangeFolderViewOldSuite( const FSSpecPtr fssPtr,
- const long viewStyle,
- const AEIdleUPP idleProcUPP );
- /*
- Send an Apple event to Finder 7.1.1 or 7.1.2 to set the view of the window
- for the folder pointed to by the FSSpec.
-
- fssPtr ==> FSSpec for the folder whose view is to be set
- viewStyle ==> A view constant, as defined in AERegistry.h
- idleProcUPP ==> nil for default, or UPP for the idle function to use
-
- Requires that the folder's window be open, otherwise an error is returned
- in the reply event.
-
- See note about idle functions above.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEChangeFolderView( const FSSpecPtr fssPtr,
- const long viewStyle,
- const AEIdleUPP idleProcUPP );
- /*
- Send an Apple event to the Finder (any version) to set the view of the window
- for the folder pointed to by the FSSpec.
-
- fssPtr ==> FSSpec for the folder whose view is to be set
- viewStyle ==> A view constant, as defined in AERegistry.h
- idleProcUPP ==> nil for default, or UPP for the idle function to use
-
- Requires that the folder's window be open, otherwise an error is returned
- in the reply event.
-
- See note about idle functions above.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEAddCustomIconToItem( const FSSpecPtr fssPtr,
- const Handle theIconSuite,
- const IconSelectorValue iconSelector,
- const AEIdleUPP idleProcUPP );
- /*
- Send an Apple event to the Finder to add a custom icon to the item
- specified by the fssPtr.
-
- fssPtr ==> The item to add the custom icon to.
- theIconSuite ==> A handle to the icon suite to install.
- iconSelector ==> An IconSelectorValue specifying which icon types
- to add (defined in Icons.h).
- idleProcUPP ==> A UPP for an idle function, or nil.
-
- See note about idle functions above.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEGetItemIconSuite( const FSSpecPtr fssPtr,
- const AEIdleUPP idleProcUPP,
- Handle *theIconSuite );
- /*
- Send an Apple event to the Finder to get the icon of the item
- specified by the fssPtr.
-
- fssPtr ==> The item to get the icon from.
- idleProcUPP ==> A UPP for an idle function, or nil.
- theIconSuite ==> A handle into which the icon suite will be returned.
- theIconSuite <== A handle to an icon suite.
-
- See note about idle functions above.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEGetEveryItemOnDesktop( const AEIdleUPP idleProcUPP,
- AEDescList *objectList );
- /*
- Send an Apple event to the Finder to get a list of Finder-style object
- for each item on the desktop. This includes files (of all types),
- folders, and volumes.
-
- idleProcUPP ==> A UniversalProcPtr for an idle function, or nil.
- objectList ==> A null AEDesc.
- <== A list containing object descriptors,
- or a null AEDesc if an error is encountered.
-
- See note about idle functions above.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEGetViewFontAndSize( const AEIdleUPP idleProcUPP,
- SInt16 *font,
- SInt16 *fontSize );
- /*
- Send an Apple event to the Finder to get the current font and font size
- as set in the Views control panel.
-
- idleProcUPP ==> A UniversalProcPtr for an idle function, or nil.
- font ==> The font ID for the current view settings.
- fontSize ==> The font size for the current view settings.
-
- You MUST supply an idle function for this routine to work, since it is
- returning data. You may use the simple handler provided in this library.
-
- See note about idle functions above.
-
- Errors
-
- -50 paramErr No idle function provided.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEUpdateItemFSS( const FSSpecPtr fssPtr );
- /*
- Send an Apple event to the Finder to update the display of the item specified
- by the FSSpec.
-
- fssPtr ==> The item whose display should be updated.
-
- No reply is returns, so none is asked for. Hence, no idle function is needed.
- */
-
- //******************************************************************************
-
- pascal OSErr MFESetProcessVisibility( const ProcessSerialNumberPtr psnPtr,
- Boolean visible );
- /*
- Send an Apple event to the Finder (any version) to set the visibility of
- a process specified by it's name.
-
- processName ==> The process' name
- visible ==> Make the process visible or not
-
- */
-
- //******************************************************************************
-
- pascal OSErr MFEUpdateItemAlias( const AliasHandle aliasHandle );
- /*
- Send an Apple event to the Finder to update the display of the item specified
- by the alias.
-
- aliasHandle ==> The item whose display should be updated.
-
- No reply is returns, so none is asked for. Hence, no idle function is needed.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEOpenFile( const FSSpec *fssPtr );
- /*
- Send an odoc Apple event to the Finder to open the item specified by the FSSpec.
-
- This routine can be used to open a file with it's creator app, launch an,
- open a control panel. Pretty much open anything you can open directly in the
- Finder by double-clicking.
-
- aliasHandle ==> The item whose display should be updated.
- idleProcUPP ==> A UniversalProcPtr for an idle function, or nil.
-
- No reply is returns, so none is asked for. Hence, no idle function is needed.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEMakeAliasFile( const FSSpecPtr sourceFSSPtr,
- const FSSpecPtr destFSSPtr,
- ConstStr63Param newName,
- const AEIdleUPP idleProcUPP );
- /*
- Send an Apple event to the Finder to create a new alias file at destFSSPtr
- location, with the file at sourceFSSPtr as the target, with newName as it's name.
-
- sourceFSSPtr ==> The target for the new alias file.
- destFSSPtr ==> The location for the new alias file.
- newName ==> The name for the new alias file.
-
- A reference to the newly created alias file will be returned. Currently this
- function ignores this result, but you could extract it if needed. You can ask
- that the result be returned as a Finder style object, as an alias, or as an FSSpec.
-
- See note about idle functions above.
- */
-
- //******************************************************************************
-
- pascal OSErr MFEMoveDiskIcon( const FSSpecPtr fssPtr,
- const Point position );
- /*
- Send set data Apple event to the Finder to change the position of the icon
- for the item specified by the FSSpec. The Finder's display of the item is
- immediately updated.
-
- NOTE: The position parameter is a Point, with it's values in y/x order,
- where as the Finder expects positions to be in x/y order. This
- routine changes the order for you.
-
- fssPtr ==> The item whose position will be changed.
- position ==> The new position for the item.
- idleProcUPP ==> A UniversalProcPtr for an idle function, or nil.
-
- No reply is returns, so none is asked for. Hence, no idle function is needed.
- */
-
- //******************************************************************************
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack()
- #endif
-
- #ifdef PRAGMA_IMPORT_OFF
- #pragma import off
- #elif PRAGMA_IMPORT
- #pragma import reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
-
- #endif // _MORE_FINDER_EVENTS_
-